﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
  <html>
    <body bgcolor="#999999">
      <div id="carrier">
        <center>
          <!-- Name of music collection -->      
          <div id="header">
            <h1>
              Music Collection: &quot;<xsl:value-of select="collection/@name"/>&quot;
            </h1>
          </div>
          <!-- List of albums will be shown in this block -->
          <div id="'albums_container">
            <table width="90%" border="0" bgcolor="#cccc99">
              <!-- Parsing and extracting properities of each album -->
              <xsl:for-each select="collection/album">
                <div id="album" style="background-color:red; margin: 6px">
                  <!-- Field of title in format %ARTIST%-%ALBUM_NAME% -->
                  <div id="album_name" style="font-size:120%; padding:2px; background-color:#FF9933; text-align:center">
                    <xsl:value-of select="band|composer|performer"/> - 
                    <xsl:value-of select="name"/><br/>
                  </div>
                  <!-- Narrow gray field with additional information like genre and year of release -->
                  <div id="album_additional_info" style="background-color:#999999; font-size:80%; text-align:right">
                    <xsl:value-of select="genre"/>, 
                    <xsl:value-of select="year"/>
                  </div>
                  <!-- Tracks container -->
                  <div id="tracks">
                    <!-- Each line of this table represent a track in an album -->
                    <table id="tracks_tab" border="0" style="background-color:#CCCCCC; width:100%;border:solid 1px black">
                      <!-- Extracting information about single tracks -->
                      <xsl:for-each select="tracks/track">
                        <tr>
                          <!-- Author of single track column, useful for albums with various artists -->
                          <td>
                            <xsl:value-of select="@author"/>
                          </td>
                          <!-- Main name column-->
                          <td>
                            <xsl:value-of select="@name"/>
                            <xsl:choose>
                            <!--We will show lyrics block data if it's not empty for particular track-->
                              <xsl:when test="lyrics">
                                <div style="margin-top: 10px; margin-bottom: 10px; font-size:80%">Lyrics available:
                                  <div id="lyrics_block" style="display: table;background-color:#999999; font-size:80%; text-align:left">
                                    <xsl:value-of select="lyrics"/>
                                  </div>
                                </div>
                              </xsl:when>
                            </xsl:choose>
                          </td>
                          <!-- Length column-->
                          <td>
                            <xsl:value-of select="@length"/>
                          </td>
                          <!-- Favourites column. It shows "fav" mark if favourite attribute in XML file for particular track contains value "yes" -->
                          <td>
                            <xsl:choose>
                              <xsl:when test="@fav='yes'">
                                fav
                              </xsl:when>
                            </xsl:choose>
                          </td>
                        </tr>
                      </xsl:for-each>
                    </table>
                  </div>
                </div>
              </xsl:for-each>
            </table>
          </div>
        </center>
      </div>
    </body>
  </html>
  </xsl:template>
</xsl:stylesheet>
